﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>商品档案列表</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="/Styles/demo.css" />
    <script src="/scripts/boot.js" type="text/javascript"></script>
</head>
<body>
    <div style="width: 100%">
        <div class="mini-toolbar" style="border-bottom: 0; padding: 0px;">
            <table style="width: 100%;">
                <tr>
                    <td style="width: 100%;">
                        @*<a class="mini-button" iconcls="icon-date-magnify" onclick="showSearchWindow()" plain="true">
                            筛选</a> <span class="separator"></span>*@
                    </td>
                    <td style="white-space: nowrap;">
                        <input id="ifexame" class="mini-combobox" textfield="text" valuefield="id" value=""
                            url="/Category/ExameItems" nullitemtext="--是否审核--" emptytext="--是否审核--" onvaluechanged="search()" />
                        <input id="Id" class="mini-textbox" emptytext="请输入编码" style="width: 150px;" onenter="onKeyEnter" />

                        <a class="mini-button" onclick="search()">查询</a>
                    </td>
                </tr>
            </table>
            <div id="searchWindow" class="mini-window" title="高级筛选" style="width: 650px; height: 220px;"
                iconcls="icon-date-magnify" showmaxbutton="true" showtoolbar="true" showfooter="true"
                showmodal="false" allowresize="false" allowdrag="true">
                <div property="footer" style="text-align: right; padding: 5px; padding-right: 15px;">
                    <a class="mini-button" iconcls="icon-zoom" onclick="advSearch()" style='vertical-align: middle;'>
                        筛选</a>
                </div>
                <form id="frmAdv">
                <table class="edittable" border="1" cellpadding="0" cellspacing="0">
                    <tr>
                        <td style="width: 80px;">
                            店内码:
                        </td>
                        <td style="width: 120px;">
                            <input name="GoodsCode" class="mini-textbox" />
                        </td>
                        <td style="width: 80px;">
                            条形码:
                        </td>
                        <td style="width: 120px;">
                            <input name="GoodsBarCode" class="mini-textbox" />
                        </td>
                        <td style="width: 80px;">
                            商品简码:
                        </td>
                        <td style="width: 120px;">
                            <input name="GoodsSubCode" class="mini-textbox" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            大类:
                        </td>
                        <td>
                            <input name="GbCode" id="GbCode" class="mini-combobox" textfield="text" valuefield="id"
                                url="/category/GetFbPaGoodsGb/" shownullitem="true" />
                        </td>
                        <td>
                            中类:
                        </td>
                        <td>
                            <input name="GmCode" id="GmCode" class="mini-combobox" textfield="text" valuefield="id"
                                url="/Category/GetFbPaGoodsGm/" shownullitem="true" />
                        </td>
                        <td>
                            小类:
                        </td>
                        <td>
                            <input name="GsCode" id="GsCode" class="mini-combobox" textfield="text" valuefield="id"
                                url="/Category/GetFbPaGoodsGs/" shownullitem="true" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            细类:
                        </td>
                        <td>
                            <input name="GlCode" id="GlCode" class="mini-combobox" textfield="text" valuefield="id"
                                url="/Category/GetFbPaGoodsGl/" shownullitem="true" />
                        </td>
                        <td>
                            商品类型:
                        </td>
                        <td>
                            <input name="GoodsType" class="mini-textbox" />
                        </td>
                        <td>
                            核算方式:
                        </td>
                        <td>
                            <input name="CheckMode" class="mini-textbox" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            供货商:
                        </td>
                        <td>
                            <input name="SupCode" class="mini-textbox" />
                        </td>
                        <td>
                            经营方式:
                        </td>
                        <td>
                            <input name="OpCode" class="mini-textbox" />
                        </td>
                        <td>
                            扣率:
                        </td>
                        <td>
                            <input name="PoolRate" class="mini-spinner" decimalplaces="2" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            商品名称:
                        </td>
                        <td>
                            <input name="GoodsName" class="mini-textbox" />
                        </td>
                        <td>
                            商品简称:
                        </td>
                        <td>
                            <input name="GoodsSubName" class="mini-textbox" />
                        </td>
                        <td>
                            拼音码:
                        </td>
                        <td>
                            <input name="PyCode" class="mini-textbox" />
                        </td>
                    </tr>
                </table>
                </form>
            </div>
        </div>
    </div>
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" url="/Archives/SearchGoodsArchiveList"
            style="width: 100%; height: 100%;" idfield="id" allowresize="false" sizelist="[20,30,50,100]"
            pagesize="20" multiselect="true" onrowclick="rowclick">
            <div property="columns">
                <div type="indexcolumn" width="30">
                </div>
                <div type="checkcolumn" width="30">
                </div>
                <div field="Id" headeralign="center" align="center" width="60">
                    店内码</div>
                <div field="GoodsName" headeralign="center" align="center" width="100">
                    名称</div>
                <div field="PyCode" headeralign="center" align="center" width="100">
                    拼音数字码</div>
                <div field="GoodsBarCode" headeralign="center" align="center" width="100">
                    条形码</div>
                @*<div name="SupName" field="SupName" headeralign="center" align="center" width="60">
                    供货商</div>*@
                <div field="PurchasePrice" headeralign="center" align="center" width="60">
                    进价</div>
                <div field="ProposePrice" headeralign="center" align="center" width="60">
                    参考价</div>
                <div field="ProducingArea" headeralign="center" align="center" width="60">
                    产地</div>
                <div field="IfExamine" headeralign="center" align="center" width="40" renderer="onReadonlyExamRender">
                    审核</div>
                @*<div field="PriceHistory" headeralign="center" align="center" width="40" renderer="onHistoryRenderer">
                    历史价格</div>*@
                <div field="Specification" headeralign="center" align="center" width="40">
                    规格</div>
                <div name="action" width="120" headeralign="center" align="center" renderer="onActionRenderer"
                    cellstyle="padding:0;">
                    管理</div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        mini.parse();

        function rowclick(e) {
            //$(e.sender).find(".Edit_Button").first().click();
            view(e.record.Id);
        }
        var grid = mini.get("datagrid1");


        grid.load();
        //对"createtime"字段，进行降级排序
        grid.sortBy("Id", "desc");


        $("#key").bind("keydown", function (e) {
            if (e.keyCode == 13) {
                search();
            }
        });


        function view(id) {
            mini.open({
                url: "/Query/ViewGoods/" + id,
                title: "产品查看",
                iconCls: "icon-user",
                allowResize: false,
                width: 700,
                height: 550,
                onload: function () {
                },
                ondestroy: function (action) {

                }
            });
        }
        function onActionRenderer(e) {
            var grid = e.sender;
            var record = e.record;
            var uid = record.Id;
            var rowIndex = e.rowIndex;

            var s = ' <a class="Edit_Button" href="javascript:view(\'' + uid + '\')" >查看</a>';
            return s;
        }



        function remove() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                if (confirm("确定删除选中记录？")) {
                    var ids = [];
                    for (var i = 0, l = rows.length; i < l; i++) {
                        var r = rows[i];
                        ids.push(r.Id);
                    }
                    var id = ids.join(',');
                    grid.loading("操作中，请稍后......");
                    deleteItem(id);
                }
            } else {
                alert("请选中一条记录");
            }
        }
        
    </script>
    <script type="text/javascript">
        mini.parse();
        var tree = mini.get("tree1");
        tree.on("nodeselect", function (e) {
            if (e.isLeaf) {
                grid.columns[6].visible = false;
                grid.load({ SupCode: e.node.Id });
            } else {
                grid.setData([]);
                grid.setTotalCount(0);
            }
        });
        function treesearch() {
            var value = mini.get("treekey").getValue();
            tree.load("/Archives/SearchAllSuppliers/" + value);
        }

        function showSearchWindow() {
            var win = mini.get("searchWindow");
            win.show();
        }
        function advSearch() {
            var frm = new mini.Form("frmAdv");
            grid.load(frm.getData(true));
            var win = mini.get("searchWindow");
            win.hide();
        }
        function search() {
            grid.load({
                "key": mini.get("#Id").value,
                "IfExamine": mini.get("#ifexame").value
            });
        }
        function onHistoryRenderer(e) {
            var grid = e.sender;
            var record = e.record;
            var uid = record.Id;
            var rowIndex = e.rowIndex;
            return "<a href='javascript:viewHistory(\"" + e.PriceHistory + "\")'>查看</a>"
        }
        function viewHistory(text) {
            var table = "<table class='mini-grid-table' border='1' cellpadding='0' cellspacing='0' style='border-color:gray;border:#d2d2d2 1px solid;'>";
            table += "<tr>";
            table += "<td>价格</td><td>时间</td>";
            table += "</tr>";
            var rows = text.split(",");
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].split("|")[0] == "undefined") {
                    break;
                }
                table += "<tr>";
                table += "<td>" + rows[i].split("|")[0] + "</td><td>" + rows[i].split("|")[1] + "</td>";
                table += "</tr>";
            }

            table += "</table>";

            mini.showMessageBox({
                width: 250,
                title: "历史价格",
                buttons: ["ok"],
                //message: "自定义Html",
                html: table,
                showModal: false,
                callback: function (action) {
                    //alert(action);
                }
            });
        }
        
    </script>
</body>
</html>
